package uk.ac.warwick.dcs.csufbo;

import java.util.ArrayList;
import java.util.Random;

public class Rule
{
	private ArrayList<Integer> premise;
	private ArrayList<Integer> conclusion;

	Rule(int premLen, int conLen)
	{
		setPremise(premLen);
		setConclusion(conLen);
	}

	Rule(ArrayList<Integer> premise, ArrayList<Integer> conclusion)
	{
		this.premise = premise;
		this.conclusion = conclusion;
	}

	public void init()
	{

	}

	public void setPremise(int length)
	{
		premise = new ArrayList<Integer>(length);
		Random randomGenerator = new Random();

		for (int i = 0; i < length; i++)
		{
			premise.add(i, randomGenerator.nextInt(11));
		}
	}

	public void setPremise(ArrayList<Integer> xPremise)
	{
		try
		{
			for (int i = 0; i < xPremise.size(); i++)
			{
				if (xPremise.get(i) > 11 || xPremise.get(i) < 0)
				{
					throw new Exception();
				}
			}

			premise = xPremise;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public void setConclusion(int length)
	{
		conclusion = new ArrayList<Integer>(length);
		Random randomGenerator = new Random();

		for (int i = 0; i < length; i++)
		{
			conclusion.add(i, randomGenerator.nextInt(11));
		}
	}

	public void setConclusion(ArrayList<Integer> xConclusion)
	{
		try
		{
			for (int i = 0; i < xConclusion.size(); i++)
			{
				if (xConclusion.get(i) > 11 || xConclusion.get(i) < 0)
				{
					throw new Exception();
				}
			}

			conclusion = xConclusion;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public ArrayList<Integer> getPremise()
	{
		return premise;
	}

	public String getStrPremise()
	{
		String tempPrem = "";
		for (int i = 0; i < premise.size(); i++)
		{
			tempPrem = tempPrem + premise.get(i).toString() + ",";
		}
		return tempPrem;
	}

	public ArrayList<Integer> getConclusion()
	{
		return conclusion;
	}

	public String getStrConclusion()
	{
		String tempPrem = "";
		for (int i = 0; i < conclusion.size(); i++)
		{
			tempPrem = tempPrem + conclusion.get(i).toString() + ",";
		}
		return tempPrem;
	}

}
